var newsTable;
function getNewsList(name) {
    if (typeof newsTable !== 'undefined') {
        newsTable.fnPageChange('first');
        return;
    }
    var i = 1;
    newsTable = $("#newsList").DataTable({
        "sAjaxSource": _path + "/files/queryByPage",
        "fnServerParams": function (aoData) {
            aoData.push(
                { "name": "status", "value": $("#status").val() },
                { "name": "fromDate", "value": $("#fromDate").val() },
                { "name": "toDate", "value": $("#toDate").val() },
                { "name": "keyType", "value": $("#keyType").val() },
                { "name": "keywords", "value": $("#keywords").val() }
            );
        },
        "sServerMethod": "POST",
        "sAjaxDataProp": "dataList",
        "fnCreatedRow": function () {
            i++;
        },
        "fnPreDrawCallback": function () {
            i = 1;
        },
        "aoColumns": [
            { "sTitle": "序号", "sWidth": "2%",
                "mData": function () {
                    return i;
                }
            },
            { "sTitle": "标题", "sWidth": "10%","mData": 
	            	function(data){
	        		var temps = '<a href="' + _path + '/files/edit/' + data.id + '" target="_blank">'+data.title+'</a>';
	        		return temps;
	        	}
	        },
            { "sTitle": "机构单位", "mData": "username", "sWidth": "10%" },
            { "sTitle": "状态", "mData": "status", "sWidth": "10%",
                "mRender": function (data) {
                    var status = '';
                    switch (data) {
                        case '5':
                            status = '主动公开';
                            break;
                        case '6':
                            status = '依申请公开';
                            break;
                        case '7':
                            status = '不予公开';
                            break;
                        case '0':
                            status = '无效';
                            break;
                        default :
                            status = '未知';
                            break;
                    }
                    return status;
                }
            },
            { "sTitle": "发布时间", "mData": "falseCreateTime", "sWidth": "10%" },
            { "sTitle": "操作", "sWidth": "10%",
                "mData": function (data) {
                		var status = '<a href="' + _path + '/files/edit/' + data.id + '" class="btn default btn-xs purple" target="_blank"><i class="fa fa-edit" title="编辑"></i></a>';
                        status += '&nbsp;<a href="' + _path + '/files/del/' + data.id + '"  class="btn default btn-xs red" target="_blank"><i class="fa fa-trash-o" title="删除"></i></a>';
//                        if(name==data.username)
//                        status += '&nbsp;<a href="' + _path + '/notice/counterSign/' + data.id +'?name='+name+ '" class="btn default btn-xs green"><i class="fa fa-edit" title="复签"></i></a>';
                        if(name!="admin")
                        status += '&nbsp;<a href="' + _path + '/files/signed/' + data.id +'?name='+name+ '" class="btn default btn-xs yellow" target="_blank"><i class="fa fa-edit" title="签收"></i></a>';
                        return status;
                }
            }
        ]
    });
}